/*
 * Copyright 2011, 2012 Fabian Wenzelmann
 * 
 * This file is part of Recognition-Procedures-for-Boolean-Functions.
 * 
 * Recognition-Procedures-for-Boolean-Functions is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Recognition-Procedures-for-Boolean-Functions is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Recognition-Procedures-for-Boolean-Functions.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.wenzelmf.booleanFunction.lpb.combinatorial.test;

import java.io.StringReader;

import de.wenzelmf.booleanFunction.dnf.DNF;
import de.wenzelmf.booleanFunction.lpb.combinatorial.occurrencePattern.TreeMapPatternFactory;
import de.wenzelmf.booleanFunction.lpb.combinatorial.solver.ClassicalTreeSolver;
import de.wenzelmf.booleanFunction.lpb.combinatorial.solver.DoubleSolverInformation;
import de.wenzelmf.booleanFunction.lpb.combinatorial.solver.MinimumChooser;
import de.wenzelmf.booleanFunction.lpb.combinatorial.splittingTree.NotSymmetricException;
import de.wenzelmf.booleanFunction.lpb.combinatorial.splittingTree.SplittingTree;
import de.wenzelmf.booleanFunction.lpb.util.ConversionException;
import de.wenzelmf.booleanFunction.lpb.util.LPB;
import de.wenzelmf.booleanFunction.lpb.util.LPBCombinatorialConstants;
import de.wenzelmf.booleanFunction.parser.BFParser;
import de.wenzelmf.booleanFunction.parser.ParseException;

/**
 * Just a test if everything works.
 * 
 * @author Fabian Wenzelmann
 * @version 1.0
 *
 */
public class ExampleOne
{
	/**
	 * The main method.
	 * 
	 * @param args Command line arguments.
	 */
	public static void main(String[] args)
	{
		BFParser parser = new BFParser(new StringReader("{ {x1, x2}, {x1, x3}, {x1, x4, x5}, {x2, x3, x4} }"));
		parser.setClauseFactory(LPBCombinatorialConstants.defaultClauseFactory);
		parser.setDNFFactory(LPBCombinatorialConstants.defaultDNFFactory);
		DNF dnf = null;
		
		try
		{
			dnf = parser.DNF();
		}
		catch(ParseException e)
		{
			e.printStackTrace();
		}
		SplittingTree t = new SplittingTree(dnf, 6, LPBCombinatorialConstants.defaultOPFactory);
		try
		{
			t.createTree(false, new TreeMapPatternFactory(), false);
			System.out.println(t);
		}
		catch(NotSymmetricException e)
		{
			e.printStackTrace();
		}
		
		try
		{
			ClassicalTreeSolver solver = new ClassicalTreeSolver(new MinimumChooser(),
					new DoubleSolverInformation());
			LPB lpb = solver.solve(t);
			System.out.println(lpb);
		}
		catch(ConversionException e)
		{
			e.printStackTrace();
		}
	}
}
